import java.util.Timer;
import java.util.TimerTask;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Ap0stoL2
 * Date: 2023-07-29
 * Time: 22:48
 */

//定时器
public class Demo21 {
    public static void main(String[] args) {
        Timer timer = new Timer();
//利用了lambda匿名内部类,TimerTask实现了runnable(重写),但相比runnable会继续一些额外的时间属性
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("定时器运行");
            }
        }, 3000);
        System.out.println("程序开始运行~~");

    }
}
